home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / Multiprocessing.p < prev    next >
Encoding:
Text File  |  1998-02-12  |  6.1 KB  |  205 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        Multiprocessing.p
  3.  
  4.      Contains:    Multiprocessing interfaces
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.1
  8.  
  9.      Copyright:    © 1996-1998 by Apple Computer, Inc. and © 1995-1997 DayStar Digital, Inc.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT Multiprocessing;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __MULTIPROCESSING__}
  28. {$SETC __MULTIPROCESSING__ := 1}
  29.  
  30. {$I+}
  31. {$SETC MultiprocessingIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __MACTYPES__}
  35. {$I MacTypes.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __CODEFRAGMENTS__}
  38. {$I CodeFragments.p}
  39. {$ENDC}
  40.  
  41.  
  42. {$PUSH}
  43. {$ALIGN POWER}
  44. {$LibExport+}
  45.  
  46. {$IFC TARGET_CPU_PPC }
  47.  
  48. CONST
  49.     MPLibrary_MajorVersion        = 1;
  50.     MPLibrary_MinorVersion        = 4;
  51.     MPLibrary_Release            = 1;
  52.     MPLibrary_DevelopmentRevision = 2;
  53.  
  54.  
  55. TYPE
  56.     MPTaskID = ^LONGINT;
  57.     MPQueueID = ^LONGINT;
  58.     MPSemaphoreID = ^LONGINT;
  59.     MPCriticalRegionID = ^LONGINT;
  60.     MPSemaphoreCount                    = UInt32;
  61.     MPTaskOptions                        = UInt32;
  62. {$IFC TYPED_FUNCTION_POINTERS}
  63.     TaskProc = FUNCTION(parameter: UNIV Ptr): OSStatus; C;
  64. {$ELSEC}
  65.     TaskProc = ProcPtr;
  66. {$ENDC}
  67.  
  68. {$IFC TYPED_FUNCTION_POINTERS}
  69.     MPRemoteProcedure = FUNCTION(parameter: UNIV Ptr): Ptr; C;
  70. {$ELSEC}
  71.     MPRemoteProcedure = ProcPtr;
  72. {$ENDC}
  73.  
  74. {$IFC TYPED_FUNCTION_POINTERS}
  75.     MPPrintfHandler = PROCEDURE(taskID: MPTaskID; format: ConstCStringPtr; args: va_list); C;
  76. {$ELSEC}
  77.     MPPrintfHandler = ProcPtr;
  78. {$ENDC}
  79.  
  80.  
  81. CONST
  82.     kDurationImmediate            = 0;
  83.     kDurationForever            = $7FFFFFFF;
  84.  
  85.     kMPNoID                        = 0;
  86.  
  87.  
  88. FUNCTION MPProcessors: UInt32; C;
  89. FUNCTION MPCreateTask(entryPoint: TaskProc; parameter: UNIV Ptr; stackSize: ByteCount; notifyQueue: MPQueueID; terminationParameter1: UNIV Ptr; terminationParameter2: UNIV Ptr; options: MPTaskOptions; VAR task: MPTaskID): OSStatus; C;
  90.  
  91. FUNCTION MPTerminateTask(task: MPTaskID; terminationStatus: OSStatus): OSStatus; C;
  92.  
  93. PROCEDURE MPExit(status: OSStatus); C;
  94.  
  95. FUNCTION MPCurrentTaskID: MPTaskID; C;
  96.  
  97. PROCEDURE MPYield; C;
  98.  
  99. FUNCTION MPCreateQueue(VAR queue: MPQueueID): OSStatus; C;
  100.  
  101. FUNCTION MPDeleteQueue(queue: MPQueueID): OSStatus; C;
  102.  
  103. FUNCTION MPNotifyQueue(queue: MPQueueID; param1: UNIV Ptr; param2: UNIV Ptr; param3: UNIV Ptr): OSStatus; C;
  104.  
  105. FUNCTION MPWaitOnQueue(queue: MPQueueID; VAR param1: UNIV Ptr; VAR param2: UNIV Ptr; VAR param3: UNIV Ptr; timeout: Duration): OSStatus; C;
  106.  
  107. FUNCTION MPCreateSemaphore(maximumValue: MPSemaphoreCount; initialValue: MPSemaphoreCount; VAR semaphore: MPSemaphoreID): OSStatus; C;
  108.  
  109.  
  110. FUNCTION MPWaitOnSemaphore(semaphore: MPSemaphoreID; timeout: Duration): OSStatus; C;
  111.  
  112. FUNCTION MPSignalSemaphore(semaphore: MPSemaphoreID): OSStatus; C;
  113.  
  114. FUNCTION MPDeleteSemaphore(semaphore: MPSemaphoreID): OSStatus; C;
  115.  
  116. FUNCTION MPCreateCriticalRegion(VAR criticalRegion: MPCriticalRegionID): OSStatus; C;
  117.  
  118. FUNCTION MPEnterCriticalRegion(criticalRegion: MPCriticalRegionID; timeout: Duration): OSStatus; C;
  119.  
  120. FUNCTION MPExitCriticalRegion(criticalRegion: MPCriticalRegionID): OSStatus; C;
  121.  
  122. FUNCTION MPDeleteCriticalRegion(criticalRegion: MPCriticalRegionID): OSStatus; C;
  123.  
  124. FUNCTION MPAllocate(size: ByteCount): LogicalAddress; C;
  125. PROCEDURE MPFree(object: LogicalAddress); C;
  126.  
  127. PROCEDURE MPBlockCopy(sourcePtr: LogicalAddress; destPtr: LogicalAddress; blockSize: ByteCount); C;
  128.  
  129. {*************************************************************************
  130.  *
  131.  *    MPTaskIsToolboxSafe() and MPRPC() were functions added by DayStar. 
  132.  *    The 1.4 MPLibrary exports the names with an underscore prefix. 
  133.  *    To work around this, #defines have been added to automatically
  134.  *    add the underscore.
  135.  *
  136.  }
  137.     MPTaskIsToolboxSafe() allows routines which are otherwise unaware that 
  138.     they are being called from an MP task to check to see if it is permissible
  139.     to make a call to the Macintosh toolbox.  (It is okay to make toolbox 
  140.     calls only if the routine is not being called from an MP task).
  141. }
  142. FUNCTION MPTaskIsToolboxSafe(task: MPTaskID): BOOLEAN; C;
  143. {
  144.     MPRPC() calls its MPRemoteProcedure parameter in the application's main 
  145.     thread when the app next calls WaitNextEvent, EventAvail, SystemTask, 
  146.     MPYield, MPWaitOnQueue, MPWaitOnSemaphore, or MPEnterCriticalRegion. The  
  147.     return value of the MPRemoteProcedure is returned as the result of MPRPC.  
  148.     The MPRemoteProcedure function can call any toolbox function except  
  149.     SystemTask (or anything that calls it).
  150. }
  151. FUNCTION MPRPC(theProc: MPRemoteProcedure; parameter: UNIV Ptr): Ptr; C;
  152.  
  153.  
  154. {*************************************************************************
  155.  *
  156.  *    The following routines were added by DayStar for debugging purposes.
  157.  *    You should not use these in shipping products.  You can tell which
  158.  *    functions are for debugging only because they begin with an underscore
  159.  *
  160.  }
  161. FUNCTION _MPIsFullyInitialized: BOOLEAN; C;
  162.  
  163. {
  164.     MPAllocateSys() does the same thing as MPAllocate() except the memory
  165.     is allocated from the system heap.
  166. }
  167. FUNCTION _MPAllocateSys(size: ByteCount): LogicalAddress; C;
  168.  
  169. FUNCTION _MPLibraryIsCompatible(versionCString: ConstCStringPtr; major: UInt32; minor: UInt32; release: UInt32; revision: UInt32): BOOLEAN; C;
  170. PROCEDURE _MPInitializePrintf(pfn: MPPrintfHandler); C;
  171. PROCEDURE _MPPrintf(format: ConstCStringPtr; ...); C;
  172.  
  173. {
  174.      MPDebugStr() works just like DebugStr() except that it is safe
  175.     to call it from an MP task.
  176. }
  177. PROCEDURE _MPDebugStr(msg: Str255); C;
  178. {
  179.  
  180.     MPStatusPString() and MPStatusCString() provide a way to translate an OSStatus
  181.     value returned from one of the MP API calls into either a Pascal string or a
  182.     C string.  Thus, if an MPLibrary function returns an error then the application
  183.     (not a task) could use the following:
  184.  
  185.     status = MPxxx( function_params );
  186.     DebugStr( MPStatusPString( status ) );
  187.     
  188. }
  189. FUNCTION _MPStatusPString(status: OSStatus): StringPtr; C;
  190. FUNCTION _MPStatusCString(status: OSStatus): ConstCStringPtr; C;
  191.  
  192. {$ENDC}  {TARGET_CPU_PPC}
  193.  
  194. {$ALIGN RESET}
  195. {$POP}
  196.  
  197. {$SETC UsingIncludes := MultiprocessingIncludes}
  198.  
  199. {$ENDC} {__MULTIPROCESSING__}
  200.  
  201. {$IFC NOT UsingIncludes}
  202.  END.
  203. {$ENDC}
  204.